package com.qinyi.framework.shiro.util;

import com.qinyi.system.domin.SysUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;

/**
 * @author wangan on 2019/6/3
 * @description
 */
public class ShiroUtils {

	public static Subject getSubject() {
		return SecurityUtils.getSubject();
	}

	public static Session getSession() {
		return getSubject().getSession();
	}

	public static SysUser getSysUser() {
		Object principal = getSubject().getPrincipal();
		SysUser user = null;
		if (principal != null) {
			BeanUtils.copyProperties(principal, user);
		}
		return user;
	}
}
